package javabasics.netty.login.codec;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import javabasics.netty.login.protocol.Packet;
import javabasics.netty.login.protocol.PacketCodeC;

/**
 * netty 提供的编码类
 *
 * @Author suxiaoxiao
 * @Date 2019/9/18 0:06
 * @Version 1.0
 */
public class PacketEncoder extends MessageToByteEncoder<Packet> {

    @Override
    protected void encode(ChannelHandlerContext ctx, Packet msg, ByteBuf out) throws Exception {
        PacketCodeC.INSTANCE.encode(out, msg);
    }

}
